home *** CD-ROM | disk | FTP | other *** search
- Path: inforamp.net!ts14-03
- From: rmorin@inforamp.net (Randy Charles Morin)
- Newsgroups: comp.lang.c++
- Subject: Re: Object constuction in function call.
- Date: Sat, 16 Mar 96 09:21:10 GMT
- Organization: MiddleWorld SoftWare
- Message-ID: <4ie16n$pc1@sam.inforamp.net>
- References: <4icmqh$8g6@insosf1.netins.net>
- NNTP-Posting-Host: ts14-03.tor.inforamp.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <4icmqh$8g6@insosf1.netins.net>,
- hhowe@trgnet.com (Harold Howe) wrote:
- >class TCorners
- > {
- > public:
- > int w,x,y,z;
- > TCorners( int a, int b, int c, int d)
- > { w=a; x=b; y=c; z=d;}
- > }
- >
- >void display_coordinates(TCorners corners)
- > {
- > cout << "corners are" << corners.w << corners.x
- > << corners.y << corners.z ;
- > }
- >
- >int main(void)
- > {
- > display_coordinates(TCorners(1,1,20,10));
- > display_coordinates(TCorners(1,5,25,15));
- > display_coordinates(TCorners(2,5,20,10));
- > }
-
- The TCorners that you declare in main() are destroyed when you exit main.
- Thus at the end of your program you have 0 objects. Here's a procedure look
- at what is happening.
-
- int main(void)
- {
- construct TCorners
- display TCorners
- construct TCorners
- display TCorners
- construct TCorners
- display TCorners
- destroy TCorners
- destroy TCorners
- destroy TCorners
- };
-
- when the TCorners lose scope, then the destroy themselves.
-
- Agrivar
-